home *** CD-ROM | disk | FTP | other *** search
Text File | 1986-01-03 | 4.8 KB | 183 lines | [TEXT/MACA] |
- /*
- * tablut.h
- */
-
- #define MYSIGN ((long) 'TBLT') /* Tablut's signature */
- #define MYFILE ((long) 'TBTF') /* game files' signature */
-
- #define WINDOWID 260 /* Resource ID of my window */
-
- /*
- * screenport - used to keep the current port from ever dangling.
- * This is a port for the whole screen.
- */
-
- #ifndef DATA
- extern
- #endif
- GrafPtr screenport;
-
- #ifndef DATA
- extern
- #endif
- WindowPtr mywindow; /* Tablut's one window */
-
- struct piecebits { /* per-piece-type image information */
- BitMap *data; /* data to be Xor'ed */
- BitMap *mask; /* bits to be cleared before drawing */
- Point etoc; /* offset from edge to center of bitmap */
- };
- #ifndef DATA
- extern
- #endif
- struct piecebits kingmaps; /* maps for the Swedish King */
- #ifndef DATA
- extern
- #endif
- struct piecebits muscmaps; /* maps for a Muscovite */
- #ifndef DATA
- extern
- #endif
- struct piecebits swedmaps; /* maps for a Swede */
-
- #ifndef DATA
- extern
- #endif
- Rect boardrect; /* rectangle enclosing the board. */
- /* ...used to see if a piece in on the board */
- #ifndef DATA
- extern
- #endif
- Point boardcenter; /* window coords of the center of the board */
-
- #ifndef DATA
- extern
- #endif
- Point squaredim; /* offset from one square to the next */
- #define SQUARESEP 1 /* width of the border between squares */
- /* ...(included in squaredim) */
-
- /*
- * (*gridp)[][] - an array (centered at [0][0]) showing what squares are
- * occupied by what pieces. The +2 border is there so that code can
- * blindly check for captures at [h-2] or [v-2] without running off the
- * edge of the array.
- */
- struct pieceimage *(*gridp)[2+9+2][2+9+2];
-
- /*
- * all pieces are stored in one array. The following defines identify
- * the pieces by their indices.
- */
-
- #define FIRSTSWEDE 0 /* index of the first swede piece */
- #define LASTSWEDE 7 /* index of the last swede piece */
- #define FIRSTMUSC 8 /* index of the first muscovite piece */
- #define LASTMUSC 23 /* index of the last muscovite piece */
- #define THEKING 24 /* index of the swedish king piece */
- #define NUMPIECES 25 /* the total number of pieces */
-
- struct pieceimage { /* per-piece image information */
- struct piecebits *class; /* class of piece (e.g, a muscovite) */
- BitMap prevlook; /* bits to restore on leaving this space */
- /* NOTE: prevlook.bounds says where we are */
- Point grid; /* current grid coordinates of the piece */
- /* ...or [NOGRID, NOGRID] if off-board */
- struct piecehome *curhome; /* valid only if on-screen but off-board */
- /* ...points to the current home of the piece */
- };
- #ifndef DATA
- extern
- #endif
- struct pieceimage piece[NUMPIECES]; /* the pieces themselves */
-
- #define NOPLACE (-1000) /* a coord where onscreen() is false */
- #define NOGRID (-100) /* a grid coordinate for a piece that is */
- /* ...off the board. */
- #define onboard(p) ((p)->grid.h != NOGRID)
- #define onscreen(p) ((p)->prevlook.bounds.right >= 0)
-
- struct piecehome {
- Point hpoint; /* home window coordinates */
- struct pieceimage *tenant; /* the piece currently at this home */
- };
- #ifndef DATA
- extern
- #endif
- struct piecehome kinghome[1]; /* the swede king's home */
- #ifndef DATA
- extern
- #endif
- struct piecehome swedhome[LASTSWEDE - FIRSTSWEDE + 1]; /* swedes' homes */
- #ifndef DATA
- extern
- #endif
- struct piecehome muschome[LASTMUSC - FIRSTMUSC + 1]; /* muscovites' homes */
- #ifndef DATA
- extern
- #endif
- struct piecehome weirdhome /* used to catch illegal curhome references */
- #ifdef DATA
- = {{10,10}, (struct pieceimage *) 0}
- #endif
- ;
-
- #ifndef DATA /*XXX should this go into draw.c alone? XXX*/
- extern
- #endif
- GrafPtr flickport; /* a temp port used to reduce flicker */
-
- #ifndef DATA
- extern
- #endif
- int insetup; /* if true, almost any move is legal */
-
- #ifndef DATA
- extern
- #endif
- short curmove; /* current move number (initial state == 0) */
- #ifndef DATA
- extern
- #endif
- short nummoves; /* number of moves in the game so far */
-
- #define blacksmove() ((curmove & 1) == 0)
-
- #ifndef DATA
- extern
- #endif
- int winner; /* who has won the game (if anyone) */
- #define NOWIN 0 /* winner == NOWIN --> no winner yet */
- #define WHITEWIN 1 /* white has won */
- #define BLACKWIN 2 /* black has won */
-
- #define BOARDBYTES 21 /* # of bytes required to store the game state */
- #define BDPERBLK 10 /* # of game-states per memory chunk */
-
- struct moveblock { /* one chunk of game-state memory */
- struct moveblock *nxtblk;
- char bytes[BOARDBYTES * BDPERBLK];
- };
- #ifndef DATA
- extern
- #endif
- struct moveblock firstblock; /* the first chunk of game-state memory */
-
- #ifndef DATA
- extern
- #endif
- int ischanged; /* "changes have been made but not stored" */
-
- #ifndef DATA
- extern
- #endif
- char gamename[128]; /* (Pascal) name of the current game file */
- #ifndef DATA
- extern
- #endif
- short gamevnum; /* volume reference number for that file */
- #ifndef DATA
- extern
- #endif
- short needsname; /* "the game needs a new name" */
-